<div class="weui-tab">
  <weui-navbar>
    <weui-navbar-item>
      {{taskDetail?.riskCheckExecution?.checkTarget?.name}}
    </weui-navbar-item>
  </weui-navbar>

  <div class="weui-tab__panel">

    <article class="weui-article pt-0 pb-0">
      <section>

        <weui-items *ngIf="taskDetail.checkDetail?.templateItemBased">
          <weui-item>
            <i weui-start style="width:20px;margin-right:5px;display:block" class="fa fa-star text-success"></i>
            <p weui-content class="mb-0">隐患大类</p>
            <p weui-last class="mb-0">{{ riskCategory?.name }}</p>
          </weui-item>
          <!--<weui-item>-->
            <!--<i weui-start style="width:20px;margin-right:5px;display:block" class="fa fa-tag text-success"></i>-->
            <!--<p weui-content class="mb-0">排查方式</p>-->
            <!--<p weui-last class="mb-0">{{taskDetail.riskCheckExecution?.checkType}}</p>-->
          <!--</weui-item>-->
          <!--<weui-item>-->
            <!--<i weui-start style="width:20px;margin-right:5px;display:block" class="fa fa-tasks text-success"></i>-->
            <!--<p weui-content class="mb-0">所属排查</p>-->
            <!--<p weui-last class="mb-0">{{taskDetail.checkDetail?.templateItemBased?.checkSource?.name}}</p>-->
          <!--</weui-item>-->
        </weui-items>

        <weui-items *ngIf="taskDetail.checkDetail?.deptBased">
          <weui-item>
            <i weui-start style="width:20px;margin-right:5px;display:block" class="fa fa-star text-success"></i>
            <p weui-content class="mb-0">隐患大类</p>
            <p weui-last class="mb-0">{{ riskCategory?.name }}</p>
          </weui-item>
          <!--<weui-item>-->
            <!--<i weui-start style="width:20px;margin-right:5px;display:block" class="fa fa-tag text-success"></i>-->
            <!--<p weui-content class="mb-0">排查方式</p>-->
            <!--<p weui-last class="mb-0">{{taskDetail.riskCheckExecution?.checkType}}</p>-->
          <!--</weui-item>-->
          <!--<weui-item>-->
            <!--<i weui-start style="width:20px;margin-right:5px;display:block" class="fa fa-tasks text-success"></i>-->
            <!--<p weui-content class="mb-0">所属排查</p>-->
            <!--<p weui-last class="mb-0">{{taskDetail.checkDetail?.deptBased?.checkSource?.name}}</p>-->
          <!--</weui-item>-->
          <weui-item>
            <i weui-start style="width:20px;margin-right:5px;display:block" class="fa fa-sitemap text-success"></i>
            <p weui-content class="mb-0">排查部门</p>
            <p weui-last class="mb-0">{{taskDetail.checkDetail?.deptBased?.deptName}}</p>
          </weui-item>
        </weui-items>

        <weui-items *ngIf="taskDetail.checkDetail?.dimensionBased">
          <weui-item>
            <i weui-start style="width:20px;margin-right:5px;display:block" class="fa fa-star text-success"></i>
            <p weui-content class="mb-0">隐患大类</p>
            <p weui-last class="mb-0">{{ riskCategory?.name }}</p>
          </weui-item>
          <!--<weui-item>-->
            <!--<i weui-start style="width:20px;margin-right:5px;display:block" class="fa fa-tag text-success"></i>-->
            <!--<p weui-content class="mb-0">排查方式</p>-->
            <!--<p weui-last class="mb-0">{{taskDetail.riskCheckExecution?.checkType}}</p>-->
          <!--</weui-item>-->
          <!--<weui-item>-->
            <!--<i weui-start style="width:20px;margin-right:5px;display:block" class="fa fa-tasks text-success"></i>-->
            <!--<p weui-content class="mb-0">所属排查</p>-->
            <!--<p weui-last class="mb-0">{{taskDetail.checkDetail?.dimensionBased?.checkSource?.name}}</p>-->
          <!--</weui-item>-->
          <weui-item>
            <i weui-start style="width:20px;margin-right:5px;display:block" class="fa fa-map-marker text-success"></i>
            <p weui-content class="mb-0">排查位置</p>
            <p weui-last class="mb-0">{{taskDetail.checkDetail?.dimensionBased?.checkTarget}}</p>
          </weui-item>
        </weui-items>
      </section>

    </article>

    <!--排查小类-->
    <article class="weui-article pt-0 mt-3">
      <section>
        <h2 class="title mb-3" style="padding-left: 15px">
          <a class="fa fa-file-text-o" style="color: #1aad19"></a>&nbsp;隐患小类
        </h2>
        <weui-items *ngIf="taskDetail?.riskCheckExecution?.status !== 'finished' && taskDetail?.taskType?.includes('startCheck'); else show_content">
          <weui-link href="javascript:;" *ngFor="let subCategoryItem of riskCategory?.subCategory;" style="text-decoration: none;" baseCls="link" (click)="action='withrisk'; createRiskReport(subCategoryItem)">
            <p weui-content class="mb-0">{{subCategoryItem.name}}</p>
            <p weui-last class="mb-0 text-danger">发现隐患</p>
          </weui-link>
        </weui-items>

        <ng-template #show_content>
          <ul class="list-group">
            <li class="list-group-item" *ngFor="let subCategoryItem of riskCategory?.subCategory;"><span class="pull-left">{{subCategoryItem.name}}</span></li>
          </ul>
        </ng-template>

      </section>
    </article>

    <article class="weui-article pt-0 mt-3">
      <section *ngIf="taskDetail?.riskCheckExecution?.reports?.length > 0">
        <h2 class="title" style="padding-left: 15px">
          <a class="fa fa-file-text-o" style="color: #1aad19"></a>&nbsp; 隐患报告
          <!--只需要填写一份隐患报告-->
          <!--<button type="button" style="margin-left: 5%" *ngIf="taskDetail.taskType?.includes('startCheck') && taskDetail?.riskCheckExecution?.reports?.length > 0 && taskDetail.status !== 'finished'"-->
                  <!--class="weui-btn weui-btn_mini weui-btn_primary" (click)="create()">-->
            <!--<i class="fa fa-plus"></i>-->
          <!--</button>-->
        </h2>
        <weui-items>
          <weui-item *ngFor="let report of taskDetail?.riskCheckExecution?.reports;">
            <div weui-content (click)="detail(report)">
              <a href="javascript:void(0);">{{report.location}} | {{report.subCategory?.name}}</a>
            </div>
            <div weui-last *ngIf="taskDetail.taskType?.includes('startCheck')">
              <weui-button color="warn" (click)="deleteReport(report)">删除</weui-button>
            </div>
            <div weui-last *ngIf="taskDetail.taskType?.includes('recheck') && taskDetail.status !== 'finished'">
              <input type="checkbox" style="width: 15px; height: 15px" autocomplete="off" data-md-icheck
                     (change)="updateRejectList($event, report.id)">
            </div>
          </weui-item>
        </weui-items>
      </section>

      <div *ngIf="taskDetail?.status !== 'finished'; else other_show" >
        <div class="button-sp-area"
             *ngIf="taskDetail?.taskType?.includes('startCheck') && !taskDetail?.taskType?.includes('startCheckComplete')">
          <weui-button color="primary" (click)="action='norisk'; submit();">没有隐患</weui-button>
          <!--<weui-button color="warn" (click)="action='withrisk'; create();">发现隐患</weui-button>-->
        </div>

        <!--初查完成恢复到微信端完成-->
        <div class="button-sp-area" *ngIf="taskDetail?.taskType?.includes('startCheckComplete')">
          <weui-button color="primary" (click)="action='complete'; submit();">初查完成</weui-button>
        </div>

        <div class="button-sp-area" *ngIf="taskDetail?.taskType?.includes('recheck')">
          <weui-button color="primary" (click)="action='approve'; submit();">复查通过</weui-button>
          <weui-button color="warn" (click)="action='reject'; submit();">复查未通过</weui-button>
        </div>

      </div>

      <ng-template #other_show>
        <!--初查完成恢复到微信端完成-->
        <div class="button-sp-area" *ngIf="taskDetail?.taskType?.includes('startCheck')">
          <weui-button color="primary" (click)="action='complete'; submit();">初查完成</weui-button>
        </div>
      </ng-template>


    </article>

  </div>
</div>

<div bsModal #taskModal="bs-modal" class="modal fade" role="dialog" aria-hidden='true'
     aria-labelledby="myModalLabel">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title pull-left">检查意见</h4>
        <button type="button" class="close pull-right" (click)="taskModal.hide()" aria-label="Close">
          <span>&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <form class="form-horizontal">
          <div class="form-group">
            <label class="col-sm-2 control-label">备注</label>
            <div class="col-sm-8">
              <input [(ngModel)]="comment" class="form-control" id="inputUsername"
                     name="inputUsername" placeholder="备注">
            </div>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary pull-left" (click)="taskModal.hide()">取消</button>
        <button type="button" class="btn btn-primary pull-right" (click)="submitComment()">确定</button>
      </div>
    </div>
  </div>
</div>

<weui-toast #toastpop status="success"></weui-toast>
